{template "head.html"}

<body scroll="no" class="h-100 cover page-sidebar-closed-hide-logo page-content-white page-header-fixed page-sidebar-fixed ">
<link href="{THEME_PATH}assets/global/css/admin.css" rel="stylesheet" type="text/css" />
<style>
    .kqb-sidebar-nav li .sub {
        z-index: 11;
    }
</style>

<div class="h-100 cover d-flex">
    <div class="js-sidebar kqb-sidebar h-100 transition500" style="overflow: scroll;">
        <div class="kqb-logo d-flex align-items-center justify-content-center" style="z-index: 11">
            <a href="{SITE_URL}" class="d-block">
                <img src="{THEME_PATH}assets/logo.png" style="height: 32px"/>
                <i class="fa fa-home h2 mb-0 text-white"></i>
            </a>
        </div>
        <ul class="js-menu list-unstyled mb-0 kqb-sidebar-nav">
            <hr class="my-0">
            {loop $menus $menu}
            <li class="js-menu-item transition500">
                <a href="javascript:;" data-url="{$menu.uri ? $router->url($menu.uri) : ''}" class="js-menu-link js-menu-link-first d-flex justify-content-between align-items-center px-4">
                    <div>
                        <i class="{$menu.icon}"></i>
                        <span>{dr_lang($menu.name)}</span>
                    </div>
                    {if $menu.left}
                    <span class="fa fa-angle-right h5 my-0"></span>
                    {/if}
                </a>
                <ul class="list-unstyled text-nowrap" style="display: none">
                    {loop $menu.left $second_menu}
                    <li class="transition500">
                        <a href="javascript:;" data-url="{$second_menu.uri ? $router->url($second_menu.uri) : ''}" class="js-menu-link js-menu-link-second menu-link-second d-flex justify-content-between align-items-center ">
                            <div>
                                <i class="{$second_menu.icon}"></i>
                                <span>{dr_lang($second_menu.name)}</span>
                            </div>
                            {if $second_menu.link}
                            <span class="fa fa-angle-right h5 my-0"></span>
                            {/if}
                        </a>
                        <ul class="sub list-unstyled text-nowrap">
                            {loop $second_menu.link $third_menu}
                            <li class="transition500">
                                <a href="javascript:;" data-url="{$router->url($third_menu.uri)}"
                                        class="js-menu-link d-block px-4">
                                    <i class="{$third_menu.icon}"></i>
                                    <span>{dr_lang($third_menu.name)}</span>
                                </a>
                            </li>
                            {/loop}
                        </ul>
                    </li>
                    {/loop}
                </ul>
            </li>
            {/loop}
        </ul>
    </div>
    <div class="h-100 kqb-scrollbar position-relative" style="background: #f7fcff;overflow: hidden; flex: 1">
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <div class="collapse navbar-collapse">
                    <ul class="nav navbar-nav navbar-right pull-right">
                        <li><a href="admin.php?c=cloud&m=update" target="right">版本升级</a></li>
                        <li><a href="javascript:dr_update_cache_all();">缓存更新</a></li>
                        <li><a href="admin.php?s=beifen&c=home&amp;m=index" target="right">网站备份</a></li>

                        <li class="dropdown head-dropdown">
                            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
                                <img alt="{$admin['username']}" class="img-circle" src="{dr_avatar($admin.uid)}" />
                                <span style="padding-top: 10px;" class="username username-hide-on-mobile"> {dr_strcut($admin['username'], 8)} </span>
                                <i class="fa fa-angle-down"></i>
                            </a>

                            <ul class="dropdown-menu dropdown-menu-default">
                                <li><a href="admin.php?c=api&amp;m=alogin&amp;id=1" target="_blank"><i
                                        class="fa fa-user"></i> 用户中心 </a></li>
                                <li><a href="admin.php?c=api&amp;m=my" target="right"><i class="fa fa-edit"></i> 修改资料
                                </a></li>
                                <li><a href="javascript:;" onclick="dr_logout('admin.php?c=login&amp;m=out');"><i
                                        class="fa fa-user-times"></i> 退出系统</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
        <iframe name="right" id="right_page" src="{dr_url('home/main')}&cache={SYS_TIME}"
                url="{dr_url('home/main')}&cache={SYS_TIME}" frameborder="false" scrolling="auto"
                style="border:none; margin-bottom:0px;" width="100%" height="auto" allowtransparency="true"></iframe>
    </div>
</div>

<script type="text/javascript">
  // 退出
  function dr_logout(url) {
    var r=confirm(lang['logout']);
    if (r==true) {
      $.ajax({
        type: "GET",
        dataType: "json",
        url: url,
        success: function(json) {
          if (json.code == 1) {
            setTimeout("window.location.href='{dr_url("login/index")}'", 1000);
          }
          dr_tips(json.code, json.msg);
        },
        error: function(HttpRequest, ajaxOptions, thrownError) {
          dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError)
        }
      });
    }
  }
  function dr_select_site(id) {
    var r=confirm('{dr_lang("你确定要切换到选中站点吗？")}')
    if (r==true) {
      window.location.href='{dr_url("api/site")}&id='+id
    }
  }

  function Mlink(top, left, link, url) {

    // 延迟提示
    /*
    var admin_loading = layer.load(2, {
        time: 1000
    });*/

    $('.dr_menu_item').hide();
    $('.dr_menu_'+top).show();
    $('.dr_menu_'+top+' .sub-menu').hide();

    $('#dr_m_top_'+top+' li').removeClass('active open');
    $('.dr_menu_'+top+' li').removeClass('active open');

    $('#dr_menu_link_'+link).addClass('active open');
    $('#dr_menu_m_link_'+link).addClass('active open');

    // 顶级菜单选择
    $('.top-menu .navbar-nav li').removeClass('open');
    $('.dr_mini_menu_top').removeClass('open');
    $('#dr_menu_top_'+top).addClass('open');
    $('#dr_mini_menu_top_'+top).addClass('open');

    // 移动端选择
    $('.fc-mb-sum-menu').hide();
    $('#dr_m_top_'+top).show();

    // 分组菜单选择
    $('.dr_menu_'+top+'').removeClass('active open');
    $('.dr_menu_'+top+' .selected').hide();
    $('.dr_menu_'+top+' .arrow').removeClass('open');

    $('#dr_menu_left_'+left).addClass('active open');
    $('#dr_menu_left_'+left+' .selected').show();
    $('#dr_menu_left_'+left+' .arrow').addClass('open');
    $('#dr_menu_left_'+left+' .sub-menu').show();

    $("#right_page").attr('src', url);
    $("#right_page").attr("url", url);
  }

  function wSize() {
    var str = getWindowSize();
    var strs = new Array(); //定义一数组
    strs = str.toString().split(","); //字符分割
    var heights = strs[0] - 50, Body = $('body');
    $('#right_page').height(heights);
  }

  if (!Array.prototype.map)
    Array.prototype.map = function (fn, scope) {
      var result = [], ri = 0;
      for (var i = 0, n = this.length; i < n; i++) {
        if (i in this) {
          result[ri++] = fn.call(scope, this[i], i, this);
        }
      }
      return result;
    };

  var getWindowSize = function () {
    return ["Height", "Width"].map(function (name) {
      return window["inner" + name] ||
        document.compatMode === "CSS1Compat" && document.documentElement["client" + name] || document.body["client" + name]
    });
  }

  $(function () {
    window.onresize = wSize;
    wSize();
    // 宽度小时
    if ($(document).width() < 900) {
      $('.page-sidebar .sidebar-toggler').click();
    }
  });

  $('.js-menu-link').click(function () {
    var url = $(this).data('url');
    if (!url) {
      return;
    }

    $('.js-menu-item').removeClass('active');
    $(this).closest('.js-menu-item').addClass('active');

    $("#right_page").attr('src', url).attr("url", url);
  });

  $('.js-toggle-menu').click(function () {
    var open = $('i', this).hasClass('fa-arrow-left');
    $('i', this).removeClass(open ? 'fa-arrow-left' : 'fa-reorder').addClass(open ? 'fa-reorder' : 'fa-arrow-left');
    $('.js-sidebar').toggleClass('min');
    setTimeout(function () {
      $('.js-sidebar').toggleClass('retract')
    }, open ? 0 : 300)
  });

  $('.js-menu-link-second').hover(function () {
    var $list = $(this).next();
    $list.css({
      top: $(this).position().top,
    });

    // 高度超出缩小
    var winHeight = $(window).height();
    if ($list.outerHeight() > winHeight) {
      $list.css({
        height: winHeight,
        overflowY: 'scroll',
      });
    }

    // 超出屏幕上移
    var bottom = $list.offset().top + $list.outerHeight();
    if (bottom > winHeight) {
      $list.css('top', winHeight - $list.outerHeight());
    }
  });

  var showed;
  $('.js-menu-link-first').click(function () {
    var list = $(this).next();
    list.slideToggle();

    if (showed && !showed.is(list)) {
      showed.slideUp();
    }

    showed = list;
  });
</script>
</body>
</html>